/*
 * 用户管理模块
 */
import { LoginFormType } from '@/interfaces/LoginType/LoginType'
import { is_user } from '../globalFun'

import getRouter from './getRouter'

// 登录
export function Router() {
  return {
    url: 'user/get_router',
    type: 'post',
    response: (config: LoginFormType): Result<Array<RouterType>> => {
      const { username } = config
      const isHave = is_user(username)
      if (isHave) {
        return {
          code: 200,
          result: getRouter,
          message: '获取路由表成功'
        }
      }
      return {
        code: 200,
        message: '获取路由表失败',
        result: null
      }
    }
  }
}
